package scparser;

import java.io.BufferedReader;
import java.io.IOException;

import javax.vecmath.Point3d;

public class ParserHelper {
	
	public static Double takeDouble(String line, String header) throws IOException{
		line=line.substring(line.indexOf(header)  + header.length() + 1);
		return Double.valueOf(line);
	}
	
	public static Point3d takePoint(String line, String header) throws IOException{
		String point = line;
		if(!point.contains(header))
			throw new IllegalArgumentException();
		point=point.substring(point.indexOf(header) + header.length() + 1 );
		String [] c = point.split(" ");
		
		return new Point3d(Double.valueOf(c[0]), Double.valueOf(c[1]), Double.valueOf(c[2]));
		
	}
	
	public static String takeString( String line, String header) throws IOException{
		String name = line;
		name = name.substring(name.indexOf(header) + header.length());
		return name.trim();
	}

}
